package com.zyinhao.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

/**
 * Created by zhangyinhao on 2018/8/16
 * Description：
 */
@RestController
public class HelloWorldController {
    @Autowired
    private Environment env;

    @Value("${test1}")
    private String testValue;
    @Value("${test2}")
    private String test2;
    @Value("${user2.name}")
    private String userName;
    @Value("${user2.age}")
    private String userAge;


    @RequestMapping("/hello1")
    public String hello1() {
        System.out.println("####测试properties属性："+testValue+"；方式二："+env.getProperty("test.aaa"));
        System.out.println("####"+env.toString());
        return "Hello World";
    }

    @RequestMapping("/hello2")
    public List<String> hello2() {
        return Arrays.asList(new String[] { "A", "B", "C" });
    }

    @RequestMapping("/hello3")
    public String hello3() {
        return testValue+";"+test2+";"+userName+";"+userAge;
    }

}
